package com.dts.evaluate.ui.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import android.widget.EditText;

import com.dts.evaluate.R;

/**
 * Created by user on 2016/9/21.
 */

public class StrokeEditText extends EditText {
    Paint paint;
    Path path;
    public StrokeEditText(Context context) {
        super(context);
        init(context);
    }

    public StrokeEditText(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public StrokeEditText(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    private void init(Context context){
        paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(1);
        paint.setColor(ContextCompat.getColor(context, R.color.list_devider_color));

        path = new Path();
    }


    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        int width = getMeasuredWidth();
        int height = getMeasuredHeight();

        path.moveTo(0,0);
        path.lineTo(width,0);
        path.lineTo(width,height);
        path.lineTo(0,height);
        path.close();

        canvas.drawPath(path,paint);
    }
}
